package com.woniu108.carService.commons.exception.exec;


import com.woniu108.carService.commos.exception.WoniuException;
import com.woniu108.carService.commos.model.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class WoniuExceptionExcutor {

    @ExceptionHandler(Throwable.class)
    public Result<?> executorThrowable(Throwable e){
        e.printStackTrace();//打印异常
        return Result.getResult().setMsg("出现异常").setCode(500);
    }

    @ExceptionHandler(WoniuException.class)
    public Result<?> executorMovieException(WoniuException e){
        e.printStackTrace();//打印异常
        return Result.getResult().setMsg(e.getMessage()).setCode(e.getCode());
    }
}
